﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Yunwei.Web.Areas.Admin.Models
{
    public class RegisterViewModel
    {
        public int Id { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [StringLength(20, MinimumLength = 4, ErrorMessage = "{2}到{1}个字符")]
        [Display(Name = "用户名")]
        public string Name { get; set; }

        /// <summary>
        /// 显示名
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [StringLength(20, MinimumLength = 2, ErrorMessage = "{2}到{1}个字符")]
        [Display(Name = "显示名")]
        public string NickName { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [Display(Name = "密码")]
        [StringLength(20,MinimumLength=6,ErrorMessage="{2}到{1}个字符")]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        /// <summary>
        /// 确认密码
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [System.ComponentModel.DataAnnotations.Compare("Password", ErrorMessage = "两次输入的密码不一致")]
        [Display(Name = "确认密码")]
        [DataType(DataType.Password)]
        public string ConfirmPassword { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [Display(Name = "邮箱")]
        [DataType(DataType.EmailAddress,ErrorMessage="Email格式不正确")]
        public string Email { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [StringLength(20, MinimumLength = 11, ErrorMessage = "{2}到{2}个字符")]
        [Display(Name = "电话")]
        public string Phone { get; set; }

        /// <summary>
        /// 验证码
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [StringLength(6, MinimumLength = 6, ErrorMessage = "验证码不正确")]
        [Display(Name = "验证码")]
        public string VerificationCode { get; set; }

        [Required]
        [Display(Name = "角色")]
        public string Role { get; set; }

        public List<SelectListItem> RoleItems
        {
            get
            {
                var items = new List<SelectListItem>();
                items.Add(new SelectListItem() { Value = "CommonUser", Text = "普通用户" });
                items.Add(new SelectListItem() { Value = "Restaurant", Text = "餐馆" });
                items.Add(new SelectListItem() { Value = "Boss", Text = "餐馆老板" });
                items.Add(new SelectListItem() { Value = "Chef", Text = "厨师" });
                items.Add(new SelectListItem() { Value = "Waiter", Text = "服务员" });
                items.Add(new SelectListItem() { Value = "Vendor", Text = "供货商" });
                items.Add(new SelectListItem() { Value = "Else", Text = "其他" });
                return items;
            }
        }
    }
}